package com.haitonghop.modules.local;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;

import com.haitonghop.R;

public class MoreActivity extends Activity implements OnClickListener {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);

		// Remove notification bar
		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.more_activity_main);

		FrameLayout layoutContactAuthor = (FrameLayout) findViewById(R.id.layoutContactAuthor);
		FrameLayout layoutFanPage = (FrameLayout) findViewById(R.id.layoutFanPage);
		FrameLayout layoutHomePage = (FrameLayout) findViewById(R.id.layoutHomePage);
		FrameLayout layoutPrivacy = (FrameLayout) findViewById(R.id.layoutPrivacy);
		FrameLayout layoutMoreApp = (FrameLayout) findViewById(R.id.layoutMoreApp);

		layoutContactAuthor.setOnClickListener(this);
		layoutFanPage.setOnClickListener(this);
		layoutHomePage.setOnClickListener(this);
		layoutPrivacy.setOnClickListener(this);
		layoutMoreApp.setOnClickListener(this);
	}

	void openBrower(String web) {
		if (web != null) {
			String url = web;
			Intent i = new Intent(Intent.ACTION_VIEW);
			i.setData(Uri.parse(url));
			startActivity(i);
		}
	}

	@Override
	public void onClick(View v) {
		Intent itent = null;
		switch (v.getId()) {
		case R.id.layoutContactAuthor:
			itent = new Intent(this, ContactMeActivity.class);
			startActivity(itent);
			break;
		case R.id.layoutFanPage:
			openBrower("https://www.facebook.com/pages/H%C3%A0i-b%E1%BB%B1a/427416300681862?ref=hl");
			break;
		case R.id.layoutHomePage:
			openBrower("http://haibl.net/");
			break;
		case R.id.layoutPrivacy:
			openBrower("http://haibl.net/site/policy.html");
			break;
		case R.id.layoutMoreApp:
			if (getString(R.string.build_store).equals("google")) {
				openBrower("https://play.google.com/store/apps/developer?id=PhiLong");
			} else {
				openBrower("http://appstore.vn/android/details?id=com.truyentranh#");
			}
			break;
		default:
			break;
		}

	}
}
